package com.cloud.controller;

import com.cloud.model.Employee;
import com.cloud.service.EmployeeService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by gang on 2019/2/27.
 */
@RestController
public class EmployeeController {
    @Resource
    private EmployeeService employeeService;

    //直接通过网页访问的话，返回的是xml格式的，要获取到json格式的返回，要用content-type: application/json;charset=UTF-8 
    @RequestMapping("/employee/list")
    public Object list(HttpServletRequest request) {
        List<Employee> employees = employeeService.getAll();
        return employees.get(0);
    }
}
